<html>
<head>
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
  <title>showim.m</title>
<link rel="stylesheet" type="text/css" href="../../m-syntax.css">
</head>
<body>
<code>
<span class=defun_kw>function</span>&nbsp;<span class=defun_out>varargout&nbsp;</span>=&nbsp;<span class=defun_name>showim</span>(<span class=defun_in>img,img_size,placement</span>)<br>
<span class=h1>%&nbsp;SHOWIM&nbsp;Displays&nbsp;given&nbsp;image(s).</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Synopsis:</span></span><br>
<span class=help>%&nbsp;&nbsp;h&nbsp;=&nbsp;showimg(img)</span><br>
<span class=help>%&nbsp;&nbsp;h&nbsp;=&nbsp;showimg(img,img_size)</span><br>
<span class=help>%&nbsp;&nbsp;h&nbsp;=&nbsp;showimg(img,img_size,placement)</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Description:</span></span><br>
<span class=help>%&nbsp;&nbsp;It&nbsp;displays&nbsp;images&nbsp;to&nbsp;the&nbsp;current&nbsp;figure.&nbsp;It&nbsp;assumes&nbsp;that&nbsp;the&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;images&nbsp;are&nbsp;represented&nbsp;as&nbsp;column&nbsp;vectors&nbsp;stored&nbsp;in&nbsp;the&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;img&nbsp;[dim&nbsp;x&nbsp;num_img]&nbsp;where&nbsp;dim=height*width.&nbsp;</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Input:</span></span><br>
<span class=help>%&nbsp;&nbsp;img&nbsp;[dim&nbsp;x&nbsp;num_img]&nbsp;Images&nbsp;store&nbsp;as&nbsp;column&nbsp;vectors&nbsp;of&nbsp;size</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;&nbsp;dim&nbsp;=&nbsp;width*height.</span><br>
<span class=help>%&nbsp;&nbsp;img_size&nbsp;[2&nbsp;1]&nbsp;Image&nbsp;size&nbsp;img_size&nbsp;=&nbsp;[height,&nbsp;width].&nbsp;The&nbsp;image</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;&nbsp;size&nbsp;does&nbsp;have&nbsp;to&nbsp;be&nbsp;geving&nbsp;for&nbsp;rectangular&nbsp;images.</span><br>
<span class=help>%&nbsp;&nbsp;placement&nbsp;[2&nbsp;1]&nbsp;Determines&nbsp;the&nbsp;number&nbsp;of&nbsp;rows&nbsp;and&nbsp;columns</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;wich&nbsp;the&nbsp;images&nbsp;are&nbsp;displayed,&nbsp;palecement&nbsp;=&nbsp;[rows,columns].</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;given&nbsp;then&nbsp;the&nbsp;placement&nbsp;is&nbsp;determined&nbsp;automatically.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Output:</span></span><br>
<span class=help>%&nbsp;&nbsp;h&nbsp;[1&nbsp;x&nbsp;num_img]&nbsp;Handles&nbsp;of&nbsp;individual&nbsp;axes.</span><br>
<span class=help>%</span><br>
<hr>
<span class=help1>%&nbsp;<span class=help1_field>(c)</span>&nbsp;Statistical&nbsp;Pattern&nbsp;Recognition&nbsp;Toolbox,&nbsp;(C)&nbsp;1999-2003,</span><br>
<span class=help1>%&nbsp;Written&nbsp;by&nbsp;Vojtech&nbsp;Franc&nbsp;and&nbsp;Vaclav&nbsp;Hlavac,</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://www.cvut.cz"&gt;Czech&nbsp;Technical&nbsp;University&nbsp;Prague&lt;/a&gt;,</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://www.feld.cvut.cz"&gt;Faculty&nbsp;of&nbsp;Electrical&nbsp;engineering&lt;/a&gt;,</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://cmp.felk.cvut.cz"&gt;Center&nbsp;for&nbsp;Machine&nbsp;Perception&lt;/a&gt;</span><br>
<br>
<span class=help1>%&nbsp;<span class=help1_field>Modificatrions:</span></span><br>
<span class=help1>%&nbsp;10-aug-2006,&nbsp;VF</span><br>
<span class=help1>%&nbsp;15-jun-2004,&nbsp;VF</span><br>
<span class=help1>%&nbsp;10-sep-2003,&nbsp;VF</span><br>
<br>
<hr>
[dim,num_data]=size(img);<br>
<br>
<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&lt;&nbsp;2,<br>
&nbsp;&nbsp;sr=sqrt(dim);<br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;fix(sr)==sr,&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;img_size&nbsp;=&nbsp;[sr,sr];&nbsp;<br>
&nbsp;&nbsp;<span class=keyword>else</span>&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class=error>error</span>(<span class=quotes>'Not&nbsp;enough&nbsp;input&nbsp;arguments.'</span>);&nbsp;<br>
&nbsp;&nbsp;<span class=keyword>end</span><br>
<span class=keyword>end</span><br>
<br>
<span class=comment>%---------------------</span><br>
<br>
<span class=keyword>if</span>&nbsp;num_data&nbsp;&gt;&nbsp;1,<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&gt;=3,<br>
&nbsp;&nbsp;&nbsp;&nbsp;row&nbsp;=&nbsp;placement(1);&nbsp;col&nbsp;=&nbsp;placement(2);<br>
&nbsp;&nbsp;<span class=keyword>else</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;col=floor(sqrt(4*num_data/3));<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>for</span>&nbsp;i=max(1,fix(num_data/10)):fix(sqrt(num_data)),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;num_data/i&nbsp;==&nbsp;round(num_data/i),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;col=&nbsp;num_data/i;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=jump>break</span>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class=keyword>end</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;row=ceil(num_data/col);<br>
&nbsp;&nbsp;<span class=keyword>end</span><br>
<br>
&nbsp;&nbsp;cnt=0;<br>
&nbsp;&nbsp;h&nbsp;=&nbsp;[];<br>
&nbsp;&nbsp;<span class=keyword>while</span>&nbsp;cnt&nbsp;&lt;&nbsp;num_data,<br>
&nbsp;&nbsp;&nbsp;&nbsp;cnt=cnt+1;<br>
&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;=&nbsp;[h,&nbsp;subplot(row,col,cnt)];<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;showim(img(:,cnt),img_size);<br>
&nbsp;&nbsp;<span class=keyword>end</span><br>
&nbsp;&nbsp;<br>
<span class=keyword>else</span><br>
&nbsp;&nbsp;h&nbsp;=&nbsp;imshow(reshape(img,img_size(1),img_size(2)),[]);<br>
<span class=keyword>end</span><br>
<br>
<span class=keyword>if</span>&nbsp;<span class=stack>nargout</span>&nbsp;&gt;&nbsp;0,<br>
&nbsp;&nbsp;<span class=stack>varargout</span>{1}&nbsp;=&nbsp;h;<br>
<span class=keyword>end</span><br>
<br>
<span class=jump>return</span>;<br>
<br>
</code>
